#ifndef LAB4FS_H__
#define LAB4FS_H__

/*
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>	*/
#include <linux/fs.h>
/*
#include <linux/statfs.h>
#include <linux/mount.h>
#include <linux/ext2_fs.h>
#include <linux/buffer_head.h>
#include <linux/pagemap.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h> */

#define FILE_INODE_NUMBER 2
#define LAB4FS_MAGIC 0xABC432

#include <linux/types.h>
//typedef __u16 __bitwise __le16;

#define LAB4FS_BLOCK_SIZE	1024
#define BLK_SIZE	1024
#define BLK_SHIFT	10
#define BLK_COUNT	1024
#define INODE_COUNT	1024

#define LAB4FS_ROOT_INO	1	// root_inode_ino=1
#define LAB4FS_INODETBL_SBLK	3	//inode-table starts from blk 3
#define LAB4FS_NBLK	14	// max 14 blks per inode
#define	LAB4FS_INODE_PER_BLK	(1024/64)	// one lab4fs-ind is 64B

#define DEF_ACCESS (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)

/// in-disk struct of an inode
struct lab4fs_inode {
	__u16 i_mode;		/* File mode */
	__u16 i_uid;		/* Low 16 bits of Owner Uid */

	__u32 i_size;		/* Size in bytes,  be file-size ???  */
	__u32 i_atime;		/* Access time */
	__u32 i_ctime;		/* Creation time */
	__u32 i_mtime;		/* Modification time */
	__u32 i_dtime;		/* Deletion Time */
	__u16 i_gid;		/* Low 16 bits of Group Id */
	__u16 i_links_count;	/* Links count */

	__u32 i_blocks;		/* Blocks count: how many blks allocated to this inode */
	__u16 i_block[LAB4FS_NBLK];	// array of data blocks of this inode

	__u32 i_flags;		/* File flags */

	//  struct buffer_head *bh;     pts to 
	//__u8  name[16];
};
/*
struct	lab4fs_inode_info {
	struct inode	vfs_inode;
};	*/

/// in-disk image of an super-blk
struct lab4fs_super {
	__u32 magic;
	__u32 blocksize;
	__u32 blocksizebits;
	__u32 blocks_count;
	__u32 inodes_count;
	__u32 free_blocks;	// num of free blocks
	__u32 free_inodes;	// num of free inodes
	__u32 flags;
	__u32 future;

	__u8 name[16];
	__u32 padding[];

};

struct lab4fs_info {
	struct buffer_head *sb_bh;	// the buffer-head that stores super-block for Lab4fs
	struct lab4fs_super *super;	// super is sb_bh->b_data   

	struct buffer_head *indmap_bh;	// buffer-head that store inode-map
	unsigned char *ind_map;	// inode_map = indmap_bh->b_data

	struct buffer_head *blkmap_bh;	// buffer-head that stores blk-map
	unsigned char *blk_map;	// blk_map = blkmap_bh->b_data
};



#endif				/* __LINUX_LAB4_FS_H */
